import Vue from 'vue'
import VueRouter from 'vue-router'
// 解决重复点击报错问题
//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location)
}
// 懒加载
const Home = () => import('../views/home/Home')
const City = () => import('../views/city/City')
const Detail = () => import('../views/detail/Detail')
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    component: Home
  },
  {
    path: '/city',
    component: City
  },
  {
    path: '/detail',
    component: Detail
  }
]

const router = new VueRouter({
  routes,
  mode: 'history'
})

export default router
